package cn.mikeal.clickmodel;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;
import org.apache.hadoop.mapreduce.Reducer;

import cn.mikeal.bean.PageViewBean;

public class ClickModel {

	/*
	 * 发送的对象PageViewBean
	 */
	static class ClickModelMapper extends Mapper<LongWritable, Text, Text, PageViewBean> {
		private Text mk = new Text();
		private PageViewBean pbean = new PageViewBean();

		@Override
		protected void map(LongWritable key, Text value, Mapper<LongWritable, Text, Text, PageViewBean>.Context context)
				throws IOException, InterruptedException {
			String[] fields = value.toString().split("\001");
			if (fields.length == 11) {

			}

		}

	}

	static class ClickModelReducer extends Reducer<Text, PageViewBean, Text, NullWritable> {
		private Text rv = new Text();
		private PageViewBean vb = new PageViewBean();

		@Override
		protected void reduce(Text key, Iterable<PageViewBean> values,
				Reducer<Text, PageViewBean, Text, NullWritable>.Context context) throws IOException, InterruptedException {
			ArrayList<PageViewBean> lists = new ArrayList<PageViewBean>();
			for (PageViewBean v : values) {
				PageViewBean pageViewBean = new PageViewBean();
			}
			Collections.sort(lists, new Comparator<PageViewBean>() {
				
				@Override
				public int compare(PageViewBean o1, PageViewBean o2) {
					if (o1 == null || o2 == null) {
						return  0;
					} else {
						return 0;
					}
				}
			});
			
		}

	}
	public static void main(String[] args) {
		
	}
}
